//
//  TableCellAddStockWatchList.m
//  iStock Global
//
//  Created by Andy on 2010/11/18.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TableCellAddStockWatchList.h"
#import "tablecellgradent.h"
#import <QuartzCore/QuartzCore.h>

@implementation TableCellAddStockWatchList
@synthesize code;
@synthesize code_add;
@synthesize name;
@synthesize id_class;
@synthesize exchange;

@synthesize name_edit;
@synthesize id_class_edit;
 

@synthesize delgete;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
        // Initialization code
		code=[[UILabel alloc]initWithFrame:CGRectMake(10, 5, 100, 20)];
        code_add=[[UILabel alloc]initWithFrame:CGRectMake(14, 5, 100, 20)]; //儲存 實際代碼 位置   
        
        exchange=[[UILabel alloc]initWithFrame:CGRectMake(10, 25, 100, 20)]; //交易所          
        name=[[UILabel alloc]initWithFrame:CGRectMake(110, 0, 300, 20)];
        id_class=[[UILabel alloc]initWithFrame:CGRectMake(110, 18, 300, 20)];		
		
        name_edit=[[UITextField alloc]initWithFrame:CGRectMake(110, 0, 180, 20)];        
        id_class_edit=[[UITextField alloc]initWithFrame:CGRectMake(110, 18, 180, 20)];	
        
		name.font=[UIFont boldSystemFontOfSize:14];
        id_class.font=[UIFont boldSystemFontOfSize:12];			
		exchange.font=[UIFont boldSystemFontOfSize:10];	        
        
        name_edit.font=[UIFont boldSystemFontOfSize:13];
        id_class_edit.font=[UIFont boldSystemFontOfSize:12];		
              
        
        name.textColor=[UIColor blackColor];
		code.textColor=[UIColor blackColor];
	 	code_add.textColor=[UIColor clearColor];//將隱藏版的字體顏色變成透明
        id_class.textColor=[UIColor blackColor];
		exchange.textColor=[UIColor redColor];        
        
        name_edit.textColor=[UIColor darkGrayColor];
        id_class_edit.textColor=[UIColor darkGrayColor];        
              
        
		//讓底色透明
		name.backgroundColor=[UIColor clearColor];
		code.backgroundColor=[UIColor clearColor];
        code_add.backgroundColor=[UIColor clearColor];        
		id_class.backgroundColor=[UIColor clearColor];
		exchange.backgroundColor=[UIColor clearColor];        
        
        name_edit.backgroundColor=[UIColor clearColor];        
        id_class_edit.backgroundColor=[UIColor clearColor];  
          
        
        
        name_edit.layer.cornerRadius=1.0f;
        name_edit.layer.masksToBounds=YES;
        name_edit.layer.borderColor=[[UIColor orangeColor] CGColor];
        name_edit.layer.borderWidth= 1.0f;
        name_edit.hidden=YES;
        name_edit.returnKeyType=UIReturnKeyDone;
        name_edit.delegate=self;
        
        id_class_edit.layer.cornerRadius=1.0f;
        id_class_edit.layer.masksToBounds=YES;
        id_class_edit.layer.borderColor=[[UIColor orangeColor] CGColor];
        id_class_edit.layer.borderWidth= 1.0f;
        id_class_edit.hidden=YES;
        id_class_edit.returnKeyType=UIReturnKeyDone;
        id_class_edit.delegate=self;        
       
                  
        
		//設定cell backgroundView 的底色漸層次 設定view tablecellgrade.h tablecellgrade.m
		//self.backgroundView = [[[tablecellgradent alloc] initWithFrame:CGRectZero] autorelease];		
		[self.contentView addSubview:name];
        [self.contentView addSubview:code];	
        [self.contentView addSubview:code_add];        
		[self.contentView addSubview:id_class];	
		[self.contentView addSubview:exchange]; 
        
        [self.contentView addSubview:name_edit];        
        [self.contentView addSubview:id_class_edit]; 
        
    }
    return self;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self.delgete edit_name_done_code:code_add.text ename:name_edit.text eid_class:id_class_edit.text];
    [textField resignFirstResponder];
    return NO; //傳回NO 表示不換行
    
}


- (void)setPosition:(UACellBackgroundViewPosition)newPosition {	
    [(tablecellgradent *)self.backgroundView setPosition:newPosition];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
	
    [super setSelected:selected animated:animated];
	
    // Configure the view for the selected state
}


- (void)dealloc {
	[name release];
	[code release];
    [code_add release];    
	[id_class release];
    [exchange release];    
    [super dealloc];
}


@end
